home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / glibc108.gz / glibc108 / glibc-1.08.1 / sysdeps / stub / exc2signal.c < prev    next >
C/C++ Source or Header  |  1994-01-25  |  2KB  |  66 lines

  1. /* Translate Mach exception codes into signal numbers.  Stub version.
  2. Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4.  
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. License, or (at your option) any later version.
  9.  
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with the GNU C Library; see the file COPYING.LIB.  If
  17. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  18. Cambridge, MA 02139, USA.  */
  19.  
  20. #include <hurd.h>
  21.  
  22. /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
  23.    into a signal number and signal subcode.  */
  24.  
  25. void
  26. _hurd_exception2signal (int exception, int code, int subcode,
  27.             int *signo, int *sigcode)
  28. {
  29.   switch (exception)
  30.     {
  31.     default:
  32.       *signo = SIGIOT;
  33.       *sigcode = exception;
  34.       break;
  35.       
  36.     case EXC_BAD_ACCESS:
  37.       if (code == KERN_PROTECTION_FAILURE)
  38.     *signo = SIGSEGV;
  39.       else
  40.     *signo = SIGBUS;
  41.       *sigcode = subcode;
  42.       break;
  43.  
  44.     case EXC_BAD_INSTRUCTION:
  45.       *signo = SIGILL;
  46.       *sigcode = 0;
  47.       break;
  48.       
  49.     case EXC_ARITHMETIC:
  50.       *signo = SIGFPE;
  51.       *sigcode = 0;
  52.       break;
  53.  
  54.     case EXC_EMULATION:        
  55.     case EXC_SOFTWARE:
  56.       *signo = SIGEMT;
  57.       *sigcode = 0;
  58.       break;
  59.       
  60.     case EXC_BREAKPOINT:
  61.       *signo = SIGTRAP;
  62.       *sigcode = 0;
  63.       break;
  64.     }
  65. }
  66.